<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title><s:text name="system.page.title"/></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery-1.8.0.js" charset="utf-8"></script>
<script type="text/javascript" src="js/ready.js" charset="utf-8"></script>
<script type="text/javascript" src="js/win.js" charset="utf-8"></script>
<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js" charset="utf-8"></script>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
	var i = <s:property value='bean.options.size()'/>;
	function addRow() {
		var o = $("#detail");
		var tr = $("<tr/>").addClass("detailtd").appendTo(o);
		$('<td style="width:10px"><img alt="删除" src="image/button/datagrid_row_collapse.gif" onclick="delRow(this);"/></td>').appendTo(tr);
		$('<td><input type="text" class="input" name="bean.options['+i+'].option_title" style="width:100%;"></td>').appendTo(tr);
		$('<td><input type="text" class="input" name="bean.options['+i+'].option_desc" style="width:100%;"></td>').appendTo(tr);
		$('<td><input type="text" class="input" name="bean.options['+i+'].option_remark" style="width:100%;"></td>').appendTo(tr);
		$('<td><input type="text" class="input" name="bean.options['+i+'].source" style="width:100%;"></td>').appendTo(tr);
		$('<td><input type="text" class="input" name="bean.options['+i+'].option_type" style="width:100%;"></td>').appendTo(tr);
		i++;
	}
	function openAnswer() {
		$.openWin({iframe:true,id:"answerWin",width:800,height:500,action:"answerselectPage.do",title:"选择样题"});
	}
	function settingAnswer(json) {
		$.closeWin("answerWin");
		$("#_num").val(json.answer_num);
		$("#_title").val(json.answer_name);
		$("#_type").val(json.answer_type);
		$("#_rule").val(json.answer_rule);
		$("#_input").val(json.input_type);
		addOption(json.options);
	}
	function addOption(data) {
		i = 0;
		$(".detailtd").remove();
		$.each(data, function() {
			var o = this;
			var _o = $("#detail");
			var tr = $("<tr/>").addClass("detailtd").appendTo(_o);
			$('<td style="width:10px"><img alt="删除" src="image/button/datagrid_row_collapse.gif" onclick="delRow(this);"/></td>').appendTo(tr);
			$('<td><input type="text" class="input" value="'+o.option_name+'" name="bean.options['+i+'].option_title" style="width:100%;"></td>').appendTo(tr);
			$('<td><input type="text" class="input" value="" name="bean.options['+i+'].option_desc" style="width:100%;"></td>').appendTo(tr);
			$('<td><input type="text" class="input" value="" name="bean.options['+i+'].option_remark" style="width:100%;"></td>').appendTo(tr);
			$('<td><input type="text" class="input" value="" name="bean.options['+i+'].source" style="width:100%;"></td>').appendTo(tr);
			$('<td><input type="text" class="input" value="" name="bean.options['+i+'].option_type" style="width:100%;"></td>').appendTo(tr);
			i++;
		});
	}
	function saveQuestionnaire() {
		formId.action = "addQuestionnaire.do";
		formId.submit();
	}
</script>
</head>
<body>
<div class="tools">
	<div class="tool">
	<ul>
		<li>
			<div onclick="saveQuestionnaire()"><img src="image/button/filesave.png" width="20" height="20"/><span><s:text name='system.button.save'/></span></div>
		</li>
	</ul>
	</div>
</div>
<s:form action="" id="formId" name="formId">
<s:hidden name="bean.project_answer_id" />
<s:hidden name="project_id"/>
<s:hidden name="code"/>
<div class="formatClass">
	<div class="formatData">
		<div class="formatTitle"><span><s:text name='rec.addquestion'/></span></div>
		<div class="formatTable" style="height:100%;">
			<table border="0" cellpadding="0" cellspacing="0" width="100%" class="formatTable">
				<s:if test="bean.project_answer_id==null">
				<tr>
					<th><s:text name='rec.projeckpi_answer.answer_num'/></th>
					<td>
						<s:textfield name="bean.answer_num" cssStyle="width:190px;" id="_num"/>
						<input type="button" value="从题库选择" onclick="openAnswer();" />
					</td>
				</tr>
				</s:if>
				<tr>
					<th><s:text name='rec.projeckpi_answer.source'/></th>
					<td><s:textfield name="bean.source" cssStyle="width:190px;"/></td>
				</tr>
				<tr>
					<th><s:text name='rec.projeckpi_answer.title'/></th>
					<td><s:textfield name="bean.title" cssStyle="width:190px;" id="_title"/></td>
				</tr>
				<tr>
					<th><s:text name='rec.projeckpi_answer.answer_type'/></th>
					<td>
						<s:select id="_type" list="@net.common.manager.DictManager@getValues('0002')" name="bean.answer_type" value="bean.answer_type" listKey="dict_num" listValue="dict_name"></s:select>
					</td>
				</tr>
				<tr>
					<th><s:text name='rec.projeckpi_answer.answer_rule'/></th>
					<td>
						<s:select id="_rule" list="@net.common.manager.DictManager@getValues('0003')" name="bean.answer_rule" value="bean.answer_rule" listKey="dict_num" listValue="dict_name" ></s:select>
					</td>
				</tr>
				<tr>
					<th><s:text name='rec.answer.input_type'/></th>
					<td>
						<s:select id="_input" list="@net.common.manager.DictManager@getValues('0004')" name="bean.input_type" value="bean.input_type" listKey="dict_num" listValue="dict_name"></s:select>
					</td>
				</tr>
				<tr>
					<th><s:text name='rec.projeckpi_answer.answer_desc'/></th>
					<td><s:textfield name="bean.answer_desc" cssStyle="width:190px;"/></td>
				</tr>
				<tr>
					<th><s:text name='rec.projeckpi_answer.answer_remark'/></th>
					<td><s:textfield name="bean.answer_remark" cssStyle="width:190px;"/></td>
				</tr>
			</table>
		</div>
		<div class="formatTitle"><span><s:text name='rec.option'/></span></div>
		<div class="y-scroll" style="height:181px;">
			<table border="0" cellpadding="0" cellspacing="0" width="100%" class="listdetail" id="detail">
				<tr class="trhead">
					<td style="width:10px"><img alt="添加" src="image/button/datagrid_row_expand.gif" onclick="addRow();"/></td>
					<td><s:text name='rec.option.option_title'/></td>
					<td><s:text name='rec.option.option_desc'/></td>
					<td><s:text name='rec.option.option_remark'/></td>
					<td><s:text name='rec.option.source'/></td>
					<td><s:text name='rec.option.option_type'/></td>
				</tr>
				<s:set name="seq" value="0"/>
				<s:iterator value="bean.options" id="l">
					<tr>
						<td style="width:10px"><img alt="删除" src="image/button/datagrid_row_collapse.gif" onclick="delRow(this);"/></td>
						<td><input type="text" class="input" value="<s:property value="#l.option_title"/>" name="bean.options[<s:property value="#seq"/>].option_title" style="width:100%;"></td>
						<td><input type="text" class="input" value="<s:property value="#l.option_desc"/>" name="bean.options[<s:property value="#seq"/>].option_desc" style="width:100%;"></td>
						<td><input type="text" class="input" value="<s:property value="#l.option_remark"/>" name="bean.options[<s:property value="#seq"/>].option_remark" style="width:100%;"></td>
						<td><input type="text" class="input" value="<s:property value="#l.source"/>" name="bean.options[<s:property value="#seq"/>].source" style="width:100%;"></td>
						<td><input type="text" class="input" value="<s:property value="#l.option_type"/>" name="bean.options[<s:property value="#seq"/>].option_type" style="width:100%;"></td>
					</tr>
					<s:set name="seq" value="#seq+1"/>
				</s:iterator>
			</table>
		</div>
	</div>
</div>
</s:form>
</body>
</html>